/**
 * Created by python on 19-3-3.
 */
let vm = new Vue({
    el: "#send",
    data: {
        // 页面中需要使用到的数据，键值对
        user_id: sessionStorage.user_id || localStorage.user_id,
        token: sessionStorage.token || localStorage.token,
        host: HOST,
        title: null,
        content: null,
        columns_list:null,
        colunm_id: null,
        // options: [
        //     { name: '牛人专区', value: 1 },
        //     { name: '机器学习', value: 2 },
        //     { name: '', value: 3 },
        //     { name: '', value: 4 },
        //     { name: '', value: 5 },
        //     { name: '', value: 6 },
        //     { name: '', value: 7 },
        //
        // ]
    },
    mounted: function () {
        // console.log(base_vm.logging_status);
        // base_vm.loading_nav();
        // CKEDITOR.replace('editor1',{"filebrowserUploadurl":"http://127.0.0.1:8000/ckeditor/ipload/"});
        CKEDITOR.replace('editor1');
        this.editor = CKEDITOR.instances.editor1;
        this.get_columns();

    },
    methods: {
        // 需要用到的函数，键值对 ，键是名称，值是匿名函数
        send_headline: function () {
            axios.post(this.host + '/send/details/', {
                column: this.colunm_id+1,
                title: this.title,
                user: this.user_id,
                content: CKEDITOR.instances.editor1.document.getBody().getText()
            }, {
                // headers: {
                //     'Authorization': 'JWT ' + base_vm.data.token,
                //     },

                responseType: 'json',
                // withCredentials: true
            })
            .then(response => {
               layer.msg('发布成功');
                location.reload()

            }).catch(error =>{
                layer.msg('发布失败')
            })
        },
        get_columns:function () {
            axios.get(this.host + '/index/', {}).then(response => {
                this.columns_list = response.data;
                parseInt(this.columns_list);
                // console.log(this.columns_list);
            });

        }
    },

})